//
//  Class1516.m
//  归档-2-任意对象的归档
//
//  Created by 沈家林 on 15/8/24.
//  Copyright (c) 2015年 沈家林. All rights reserved.
//

#import "Class1516.h"
#import "Student.h"
#import "NSObject+MZBlockKVO.h"
@implementation Class1516

-(id)init{
    if (self=[super init]) {
        _studentsArray=[[NSMutableArray alloc]init];
    }
    return self;
}

-(void)addStudentsWithName:(NSString *)name age:(NSUInteger)age{
    Student *stu=[[Student alloc]init];
    stu.name=name;
    stu.age=age;
    [_studentsArray addObject:stu];
}

-(void)showStudents{
    for (Student *stu in _studentsArray) {
        NSLog(@"姓名:%@ 年龄:%lu",stu.name,stu.age);
    }
}

-(void)encodeWithCoder:(NSCoder *)aCoder{
//    [aCoder encodeObject:_studentsArray forKey:@"studentArray"];
    [self mzSaveAllAttrWithCoder:aCoder];
}

-(id)initWithCoder:(NSCoder *)aDecoder{
    if (self=[super init]) {
        _studentsArray=[aDecoder decodeObjectForKey:@"studentArray"];
        [self mzReadAllAttrWithDecoder:aDecoder];
    }
    return self;
}


@end
